#!/bin/bash

# 遍历当前目录下所有的 PNG 文件
for file in *.png; do
    if [ -f "$file" ]; then
        # 获取图片的宽度和高度
        width=$(sips -g pixelWidth "$file" | awk '/pixelWidth/ {print $2}')
        height=$(sips -g pixelHeight "$file" | awk '/pixelHeight/ {print $2}')

        # 检查尺寸是否不为 128x128
        if [ "$width" -ne 128 ] || [ "$height" -ne 128 ]; then
            # 调整图片尺寸为 128x128
            sips -z 128 128 "$file" >/dev/null 2>&1
            echo "Resized $file to 128x128."
        else
            echo "$file is already 128x128, skipped."
        fi
    fi
done    